From ea0b436b80b3abb69d62495a71ac3a3460a338fb Mon Sep 17 00:00:00 2001 From: "adam@ipcoast.com" Date: Fri, 10 Feb 2006 02:05:26 +0100 Subject: [PATCH] Fix xm-test network tests to work with hvm support enabled. --- tools/xm-test/lib/XmTestLib/Network.py | 26 ++++++++++++++++--- .../network/02_network_local_ping_pos.py | 6 ++++- .../tests/network/05_network_dom0_ping_pos.py | 10 +++++-- .../tests/network/11_network_domU_ping_pos.py | 6 ++++- 4 files changed, 41 insertions(+), 7 deletions(-) diff --git a/tools/xm-test/lib/XmTestLib/Network.py b/tools/xm-test/lib/XmTestLib/Network.py index 41863f3368..d9d12c5439 100644 --- a/tools/xm-test/lib/XmTestLib/Network.py +++ b/tools/xm-test/lib/XmTestLib/Network.py @@ -25,6 +25,7 @@ import atexit; from Test import * from Xm import * +from config import * class NetworkError(Exception): def __init__(self, msg): @@ -36,6 +37,9 @@ class NetworkError(Exception): def undo_dom0_alias(eth, ip): traceCommand("ip addr del " + ip + " dev " + eth) +def net_from_ip(ip): + return ip[:ip.rfind(".")] + ".0/24" + class XmNetwork: def __init__(self): @@ -56,14 +60,21 @@ class XmNetwork: domnum = int(dom[len("dom"):]) return "169.254."+ str(ethnum+153) + "." + str(domnum+10) - def ip(self, dom, interface, todomname=None, toeth=None): + def ip(self, dom, interface, todomname=None, toeth=None, bridge=None): newip = self.calc_ip_address(dom, interface) # If the testcase is going to talk to dom0, we need to add an # IP address in the proper subnet if dom == "dom0": - # The domain's vif is a convenient place to add to - vifname = "vif" + str(domid(todomname)) + "." + toeth[3:] + if ENABLE_HVM_SUPPORT: + # HVM uses ioemu which uses a bridge + if not bridge: + SKIP("no bridge supplied") + else: + vifname = bridge + else: + # The domain's vif is a convenient place to add to + vifname = "vif" + str(domid(todomname)) + "." + toeth[3:] # register the exit handler FIRST, just in case atexit.register(undo_dom0_alias, vifname, newip) @@ -73,6 +84,15 @@ class XmNetwork: " dev " + vifname) if status: SKIP("\"ip addr add\" failed") + + if ENABLE_HVM_SUPPORT: + # We need to add a route to the bridge device + network = net_from_ip(newip) + status, output = traceCommand("ip route add " + network + " dev " + vifname + " scope link") + + if status: + SKIP("\"ip route add\" failed") + return newip def mask(self, dom, interface): diff --git a/tools/xm-test/tests/network/02_network_local_ping_pos.py b/tools/xm-test/tests/network/02_network_local_ping_pos.py index b1952cf0f5..3a673cf8cb 100644 --- a/tools/xm-test/tests/network/02_network_local_ping_pos.py +++ b/tools/xm-test/tests/network/02_network_local_ping_pos.py @@ -28,7 +28,11 @@ ip = Net.ip("dom1", "eth0") mask = Net.mask("dom1", "eth0") # Fire up a guest domain w/1 nic -config = {"vif" : ['ip=%s' % ip]} +if ENABLE_HVM_SUPPORT: + config = {"vif" : ['type=ioemu']} +else: + config = {"vif" : ['ip=%s' % ip ]} + domain = XmTestDomain(extraConfig=config) try: domain.start() diff --git a/tools/xm-test/tests/network/05_network_dom0_ping_pos.py b/tools/xm-test/tests/network/05_network_dom0_ping_pos.py index 0d218ca0bc..7e87c43959 100644 --- a/tools/xm-test/tests/network/05_network_dom0_ping_pos.py +++ b/tools/xm-test/tests/network/05_network_dom0_ping_pos.py @@ -31,7 +31,13 @@ except NetworkError, e: FAIL(str(e)) # Fire up a guest domain w/1 nic -config = {"vif" : ["ip=%s" % ip]} +if ENABLE_HVM_SUPPORT: + brg = "xenbr0" + config = {"vif" : ['type=ioemu, bridge=%s' % brg]} +else: + config = {"vif" : ['ip=%s' % ip ]} + brg = None + domain = XmTestDomain(extraConfig=config) try: domain.start() @@ -52,7 +58,7 @@ except ConsoleError, e: try: # Add a suitable dom0 IP address - dom0ip = Net.ip("dom0", "eth0", todomname=domain.getName(), toeth="eth0") + dom0ip = Net.ip("dom0", "eth0", todomname=domain.getName(), toeth="eth0", bridge=brg) except NetworkError, e: FAIL(str(e)) diff --git a/tools/xm-test/tests/network/11_network_domU_ping_pos.py b/tools/xm-test/tests/network/11_network_domU_ping_pos.py index 6b4c2a5e52..b35aea9dae 100644 --- a/tools/xm-test/tests/network/11_network_domU_ping_pos.py +++ b/tools/xm-test/tests/network/11_network_domU_ping_pos.py @@ -18,7 +18,11 @@ pingsizes = [ 1, 48, 64, 512, 1440, 1500, 1505, 4096, 4192, from XmTestLib import * def netDomain(ip): - config = {"vif" : ["ip=%s" % ip]} + if ENABLE_HVM_SUPPORT: + config = {"vif" : ['type=ioemu']} + else: + config = {"vif" : ['ip=%s' % ip ]} + dom = XmTestDomain(extraConfig=config) try: dom.start() -- 2.30.2